<template>
  <div>
      <el-form :inline="true" class="demo-form-inline" :model="search">
      <el-select v-model="search.update_user" placeholder="指派人员" style="width:150px">
        <el-option value="" >指派人员</el-option>
        <el-option v-for="item in user" :key="item.update_user" 
        :label="item.update_user" :value="item.update_user">
        </el-option>
      </el-select>
      <el-select v-model="search.id2" placeholder="项目名称" style="width:150px">
        <el-option value="" >项目名称</el-option>
        <el-option v-for="item1 in getName" :key="item1.project_name" 
        :label="item1.project_name" :value="item1.id">
        </el-option>
      </el-select>
       <el-form-item>
        <el-date-picker v-model="search.starTime" type="date" placeholder="选择检查日期"></el-date-picker> --
      </el-form-item>
      <el-form-item>
        <el-date-picker v-model="search.endTime" type="date" placeholder="选择检查日期"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="select">检索</el-button>
      </el-form-item>
    </el-form>
    <h1 style="text-align: center; margin-top: 30px; margin-bottom: 30px">质量整改列表</h1>
    <div>
      <el-table :data="personnel">
        <el-table-column prop="id" label="整改编号"></el-table-column>
        <el-table-column prop="name" label="填报人"></el-table-column>
        <el-table-column prop="project_name" label="项目名称"> </el-table-column>
        <el-table-column prop="rect_part" label="部位"> </el-table-column>
        <el-table-column prop="update_user" label="指派人员"></el-table-column>
        <el-table-column prop="assign_date" label="指派时间"></el-table-column>
        <el-table-column prop="ask_done_date" label="整改时间"></el-table-column>
        <el-table-column prop="rectification_content" label="整改内容"></el-table-column>
        <el-table-column prop="rectification_feedback" label="整改情况反馈"></el-table-column>
        <el-table-column prop="approve_status1" label="流程状态"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-dropdown @command="handleClick">
              <el-button type="primary">
                操作<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item :command="{ row: scope.row, type: '删除' }">删除</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
          </el-table-column >
      </el-table>
    </div>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      user: {}, //高级检索对象
      getName:{},
      personnel: [], //表格数据
      row: {},
      search:{},
    };
  },
  methods: {
      select(){
        console.log(this.search)
        this.personnel=[];
        axios.get(`http://localhost/GetList/abarbeitung`,{
           params:{
               "update_user":this.search.update_user,
               "id2":this.search.id2,
               "starTime":this.search.starTime,
               "endTime":this.search.endTime,
           }
       }).then((response) => {
          this.personnel=response.data;

      });
   },
      //查询
    getpersonnel(){
       axios.get(`http://localhost/GetList/abarbeitung`).then((response) => {
          this.personnel=response.data;
      });
   },
    // 下拉框查询
   getuser(){
      axios.get(`http://localhost/GetList/getUserName`).then((response) => {
        this.user = response.data;
      });
   },
   getname(){
        axios.get(`http://localhost/GetList/getName`).then((response) => {
          this.getName = response.data;
      });
   },
   handleClick(command) {
      this.row = command.row;
      var val = command.type;
      if (val == "删除") {
        this.del(this.row.id);
      }
    },
    //删除团队信息
    del(personnel) {
      axios.delete(`http://localhost/GetList/del/${personnel}`).then(() => {
        this.getpersonnel();
      });
    },
  
  },
  created() {
    this.getpersonnel();
    this.getuser();
    this.getname();
  },
};
</script>